<?php
require_once 'glob.php';
$goodsid=$_REQUEST['id'];
$sql='select a.id as id,a.overtime as overtime,a.name as name,a.bigimg as bigimg,a.name_dic as name_dic,a.description as description,a.other_dic as other_dic,a.them_says as them_says,a.we_syas as we_syas,a.groupprice as groupprice,costprice,(a.costprice-a.groupprice) as save,a.salenum as salenum,a.smallnum as smallnum,a.bignum as bignum,ROUND(((a.groupprice/a.costprice)*10),1) as agio,b.name as bname,b.addr as baddr,b.tel as btel,b.url as burl from sn_group_goods as a left join sn_group_menchant as b on (a.merchant_id=b.id) where a.id = "'.$goodsid.'"';
$goodsinfo=$db->getrow($sql);
$xueniao->assign('goodsinfo',$goodsinfo);
if($goodsinfo['overtime']>date('Y-m-d H:i:s')){

	if($goodsinfo['salenum']>=$goodsinfo['smallnum']){

		if($goodsinfo['salenum']==$goodsinfo['bignum']||$goodsinfo['salenum']>=$goodsinfo['bignum']){

			$xueniao->assign('groupmsg','<p class="deal-buy-tip-top"><strong>'.$goodsinfo['salenum'].'</strong>
人购买</p>
<p class="deal-buy-tip-notice">谢谢您的支持，欢迎下次再来！</p><img src="'.$siteinfo_c['tempath'].'inc/i/bg-sold-out.gif" />');
				
			$salesatus='goodsover';
		}else{

			$xueniao->assign('groupmsg','<p class="deal-buy-tip-top"><strong>'.$goodsinfo['salenum'].'</strong>
人已购买</p>
<p class="deal-buy-tip-notice">数量有限，下单要快哟</p>
<p class="deal-buy-on">团购已成功，<br/>可继续购买…</p>
<p class="deal-buy-tip-btm">已达到最低团购人数：<strong>'.$goodsinfo['smallnum'].'</strong>
人</p>');
			$salesatus='go';
		}
	}else{
		/*
		 $xueniao->assign('isgroup','达到的团购最少人数需要<strong>'.$goodsinfo['smallnum'].'</strong>
		 人');
		 $xueniao->assign('groupmsg','团购进行中<br>欢迎购买…');
		 */
		$xueniao->assign('groupmsg','<p class="deal-buy-tip-top"><strong>'.$goodsinfo['salenum'].'</strong>
人已购买</p>
<p class="deal-buy-tip-notice">数量有限，下单要快哟</p>
<p class="deal-buy-on">团购进行中<br>欢迎购买…</p>
<p class="deal-buy-tip-btm">达到的团购最少人数需要<strong>'.$goodsinfo['smallnum'].'</strong>
人</p>');

		$salesatus='go';

	}

}else{

	if($goodsinfo['salenum']>=$goodsinfo['smallnum']){

		if($goodsinfo['salenum']==$goodsinfo['bignum']||$goodsinfo['salenum']>=$goodsinfo['bignum']){
			$xueniao->assign('groupmsg','<p class="deal-buy-tip-top"><strong>'.$goodsinfo['salenum'].'</strong>
人购买</p>
<p class="deal-buy-tip-notice">谢谢您的支持，欢迎下次再来！</p><img src="'.$siteinfo_c['tempath'].'inc/i/bg-sold-out.gif" />');
				
			$salesatus='goodsover';
		}else{
				
			$xueniao->assign('groupmsg','<p class="deal-buy-tip-top"><strong>'.$goodsinfo['salenum'].'</strong>
人购买</p>
<p class="deal-buy-tip-notice">谢谢您的支持，欢迎下次再来！</p><img src="'.$siteinfo_c['tempath'].'inc/i/bg-deal-expired-success.gif" />');

			$salesatus='timeover';
		}
	}else{

		$xueniao->assign('groupmsg','<p class="deal-buy-tip-top"><strong>'.$goodsinfo['salenum'].'</strong>
人购买</p>
<p class="deal-buy-tip-notice">谢谢您的支持，欢迎下次再来！</p><img src="'.$siteinfo_c['tempath'].'inc/i/bg-deal-expired-fail.gif" />');

		$salesatus='timeover';

	}


}
$xueniao->assign('thtime',thtime( $goodsinfo['overtime']));
$xueniao->assign('salesatus',$salesatus);


$xueniao->display('index.htm');

?>